home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / KoPictureKey.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-05-30  |  4.7 KB  |  155 lines

  1. /* This file is part of the KDE project
  2.    Copyright (c) 2001 Simon Hausmann <hausmann@kde.org>
  3.    Copyright (C) 2002, 2004 Nicolas GOUTTE <goutte@kde.org>
  4.  
  5.    This library is free software; you can redistribute it and/or
  6.    modify it under the terms of the GNU Library General Public
  7.    License as published by the Free Software Foundation; either
  8.    version 2 of the License, or (at your option) any later version.
  9.  
  10.    This library is distributed in the hope that it will be useful,
  11.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.    Library General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU Library General Public License
  16.    along with this library; see the file COPYING.LIB.  If not, write to
  17.    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18.  * Boston, MA 02110-1301, USA.
  19. */
  20. #ifndef __koPictureKey_h__
  21. #define __koPictureKey_h__
  22.  
  23. #include <qstring.h>
  24. #include <qdatetime.h>
  25. #include <koffice_export.h>
  26. /**
  27.  * \file koPictureKey.h
  28.  * \todo correct documentation (for example: sed "s/image/picture/g")
  29.  */
  30.  
  31. class QDomElement;
  32.  
  33. namespace KoPictureType
  34. {
  35.     /**
  36.      * QPicture version used by KoPictureClipart
  37.      *
  38.      * Possible values:
  39.      * \li 3 for Qt 2.1.x and later Qt 2.x
  40.      * \li 4 for Qt 3.0
  41.      * \li 5 for Qt 3.1 and later Qt 3.x
  42.      * \li -1 for current Qt
  43.      */
  44.     const int formatVersionQPicture=-1;
  45.  
  46.     enum Type
  47.     {
  48.         TypeUnknown = 0,    ///< Unknown or not-an-image @see KoPictureBase
  49.         TypeImage,          ///< Image, QImage-based @see KoPictureImage
  50.         TypeEps,            ///< Encapsulated Postscript @see KoPictureEps
  51.         TypeClipart,        ///< Clipart, QPicture-based @see KoPictureClipart
  52.         TypeWmf             ///< WMF (Windows Meta File) @see KoPictureWmf
  53.     };
  54. }
  55.  
  56. /**
  57.  * KoPictureKey is the structure describing a picture in a unique way.
  58.  * It currently includes the original path to the picture and the modification
  59.  * date.
  60.  *
  61.  * @short Structure describing a picture on disk
  62.  *
  63.  * @note We use the *nix epoch (1970-01-01) as a time base because it is a valid date.
  64.  * That way we do not depend on a behaviour of the current QDateTime that might change in future versions of Qt
  65.  * and we are also nice to non-Qt programs wanting to read KOffice's files.
  66.  *
  67.  * @note This behaviour is also needed for re-saving KWord files having \<FORMAT id="2"\>. When saving again,
  68.  * these files get a \<KEY\> element as child of \<PIXMAPS\> but not one as child of \<FORMAT\> and \<IMAGE\>.
  69.  * Therefore we need to be careful that the key remains compatible to default values 
  70.  * (another good reason for the *NIX epoch)
  71.  *
  72.  * @note In case of a remote path, the "original path" is the name of the temporary file that was
  73.  *  used to download the file.
  74.  */
  75. class KOFFICEUI_EXPORT KoPictureKey
  76. {
  77. public:
  78.     /**
  79.      * Default constructor. Creates a null key
  80.      */
  81.     KoPictureKey();
  82.  
  83.     /**
  84.      * @brief Constructs a key, from a filename and a modification date
  85.      *
  86.      * Storing the modification date as part of the key allows the user
  87.      * to update the file and import it into the application again, without
  88.      * the application reusing the old copy from the collection.
  89.      */
  90.     KoPictureKey( const QString &fn, const QDateTime &mod );
  91.  
  92.     /**
  93.      * Constructs a key from a filename 
  94.      * @note The modification date is set to 1970-01-01
  95.      */
  96.     KoPictureKey( const QString &fn );
  97.  
  98.     /**
  99.      * Copy constructor
  100.      */
  101.     KoPictureKey( const KoPictureKey &key );
  102.  
  103.     /**
  104.      * Assignment operator
  105.      */
  106.     KoPictureKey &operator=( const KoPictureKey &key );
  107.  
  108.     /**
  109.      * Comparison operator
  110.      */
  111.     bool operator==( const KoPictureKey &key ) const;
  112.  
  113.     /**
  114.      * Comparison operator 
  115.      * @note Used for sorting in the collection's map
  116.      */
  117.     bool operator<( const KoPictureKey &key ) const;
  118.  
  119.     /**
  120.      * Convert this key into a string representation of it
  121.      */
  122.     QString toString() const;
  123.  
  124.     /**
  125.      * Save this key in XML (as %KOffice 1.3)
  126.      */
  127.     void saveAttributes( QDomElement &elem ) const;
  128.  
  129.     /**
  130.      * Load this key from XML (as %KOffice 1.3)
  131.      */
  132.     void loadAttributes( const QDomElement &elem );
  133.  
  134.     /**
  135.      * First part of the key: the filename
  136.      */
  137.     QString filename() const { return m_filename; }
  138.  
  139.     /**
  140.      * Second part of the key: the modification date
  141.      */
  142.     QDateTime lastModified() const { return m_lastModified; }
  143.  
  144.     /**
  145.      * Sets the key according to @p filename, including modification time
  146.      */
  147.     void setKeyFromFile (const QString& filename);
  148.  
  149. protected:
  150.     QString m_filename;
  151.     QDateTime m_lastModified;
  152. };
  153.  
  154. #endif /* __koPictureKey_h__ */
  155.